package Chuong07;

import java.io.*;

public class Bai02{

	ObjectInputStream readSoon;
	ObjectOutputStream writeSole, writeSochan;
	
	String path = "D:/Hoc Tap/Hoc Ki VII/Chuyen De Java/OnTap_Code/OnTap/src/Chuong07/File/";
	//String path = "Z:/";
	
	public Bai02(){
		try{
			
			readSoon = new ObjectInputStream(
					new FileInputStream(path + "sonn.dat"));
			writeSochan = new ObjectOutputStream(
					new FileOutputStream(path + "even.dat"));
			writeSole = new ObjectOutputStream(
					new FileOutputStream(path + "odd.dat"));
			
			for(int i = 0; i < 100; i++){
				int n = readSoon.readInt();
				//System.out.println(i+": "+n);
				if(n%2 == 0){
					writeSochan.writeInt(n);
					//System.out.println(i+": "+n + "chan");
				}else{
					writeSole.writeInt(n);
					//System.out.println(i+": "+n + "le");
				}
			}
		
		}catch (FileNotFoundException ex) {
			ex.printStackTrace();
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		try{
			readSoon.close();
			writeSochan.close();
			writeSole.close();
		}catch (IOException ex) {
			ex.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		new Bai02();

	}

}
